package com.jvyou.common.exception;

import com.jvyou.common.enums.result.ErrorShowType;
import com.jvyou.common.enums.result.HttpCodeEnum;
import lombok.Getter;

/**
 * @author 橘柚
 * @version 1.0-SNAPSHOT
 * @Date 2023/2/4 1:10
 * @Description 业务异常
 */
@Getter
public class AppException extends RuntimeException {

    private static final long serialVersionUID = 4566597160469627835L;

    private final int code;

    private final String msg;

    private final ErrorShowType showType;

    public AppException(HttpCodeEnum httpCodeEnum) {
        super(httpCodeEnum.getMsg());
        this.code = httpCodeEnum.getCode();
        this.msg = httpCodeEnum.getMsg();
        this.showType = httpCodeEnum.getShowType();
    }

    public AppException(HttpCodeEnum httpCodeEnum, String msg) {
        this.code = httpCodeEnum.getCode();
        this.msg = msg;
        this.showType = httpCodeEnum.getShowType();
    }

    public AppException(Integer code, String message, ErrorShowType showType) {
        super(message);
        this.code = code;
        this.msg = message;
        this.showType = showType;
    }
}